{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "33.8921568627451\n"
     ]
    }
   ],
   "source": [
    "def get_fee_config_v1():\n",
    "    fees = [\n",
    "        {\n",
    "            \"start\": 0,\n",
    "            \"end\": 0.1,\n",
    "            \"yunFee\": 87,\n",
    "            \"guahaoFee\": 20,\n",
    "        },\n",
    "        {\n",
    "            \"start\": 0.1,\n",
    "            \"end\": 0.2,\n",
    "            \"yunFee\": 97,\n",
    "            \"guahaoFee\": 18,\n",
    "        },\n",
    "        {\n",
    "            \"start\": 0.2,\n",
    "            \"end\": 0.45,\n",
    "            \"yunFee\": 95,\n",
    "            \"guahaoFee\": 16,\n",
    "        },\n",
    "        {\n",
    "            \"start\": 0.45,\n",
    "            \"end\": 0.7,\n",
    "            \"yunFee\": 93,\n",
    "            \"guahaoFee\": 16,\n",
    "        },\n",
    "        {\n",
    "            \"start\": 0.7,\n",
    "            \"end\": 2,\n",
    "            \"yunFee\": 93,\n",
    "            \"guahaoFee\": 9,\n",
    "        },\n",
    "        {\n",
    "            \"start\": 2,\n",
    "            \"end\": 30,\n",
    "            \"yunFee\": 85,\n",
    "            \"guahaoFee\": 9,\n",
    "        },\n",
    "    ]\n",
    "    return fees\n",
    "def get_fee_config_v2():\n",
    "    fees = [\n",
    "        {\n",
    "            \"start\": 0,\n",
    "            \"end\": 0.1,\n",
    "            \"yunFee\": 110,\n",
    "            \"guahaoFee\": 20,\n",
    "        },\n",
    "        {\n",
    "            \"start\": 0.1,\n",
    "            \"end\": 0.2,\n",
    "            \"yunFee\": 120,\n",
    "            \"guahaoFee\": 18,\n",
    "        },\n",
    "        {\n",
    "            \"start\": 0.2,\n",
    "            \"end\": 0.45,\n",
    "            \"yunFee\": 118,\n",
    "            \"guahaoFee\": 16,\n",
    "        },\n",
    "        {\n",
    "            \"start\": 0.45,\n",
    "            \"end\": 0.7,\n",
    "            \"yunFee\": 116,\n",
    "            \"guahaoFee\": 16,\n",
    "        },\n",
    "        {\n",
    "            \"start\": 0.7,\n",
    "            \"end\": 2,\n",
    "            \"yunFee\": 116,\n",
    "            \"guahaoFee\": 9,\n",
    "        },\n",
    "        {\n",
    "            \"start\": 2,\n",
    "            \"end\": 30,\n",
    "            \"yunFee\": 108,\n",
    "            \"guahaoFee\": 9,\n",
    "        },\n",
    "    ]\n",
    "    return fees\n",
    "def get_fee(weight):\n",
    "    fees = get_fee_config_v2()\n",
    "    for fee in fees:\n",
    "        if weight > fee[\"start\"] and weight <= fee[\"end\"]:\n",
    "            return fee[\"yunFee\"], fee[\"guahaoFee\"]\n",
    "    \n",
    "    return 0,0\n",
    "\n",
    "def compute_price(original_price: '原价',express_freight: '国内快递费',product_weight: '重量')->float:\n",
    "    \"\"\"\n",
    "    Args:\n",
    "    original_price: 原价\n",
    "    express_freight: 国内快递费\n",
    "    product_weight: 重量\n",
    "    # 采购成本：3.5+8=11.5\n",
    "    # 产品重量：0.06+0.05=0.11\n",
    "    # 国际运费：产品重量0.11x运费97+挂号费18=28.67 x 中转仓1.15=32.97\n",
    "    # 商品定价：采购成本11.5+国际运费32.97+利润30=74.47 ÷ 美国汇率7.2=10.34÷佣金0.85 = 12.16\n",
    "\n",
    "    #原价\n",
    "    # originalPrice = 3.5\n",
    "    #国内快递费\n",
    "    # expressFreight = 11.5\n",
    "    #采购成本\n",
    "    \"\"\"\n",
    "    purchasing_cost = original_price + express_freight\n",
    "\n",
    "    #产品重量\n",
    "    #product_weight = 0.06\n",
    "    weight_fix = 0.05\n",
    "    weight = product_weight + weight_fix\n",
    "    fee = get_fee(weight)\n",
    "    yunfei = fee[0]\n",
    "    guahaofei = fee[1]\n",
    "    \n",
    "    liRUN = 30\n",
    "    if yunfei <= 0 and guahaofei <=0 :\n",
    "        raise ValueError(\"费用异常\")\n",
    "    international_freight = (weight * yunfei + guahaofei)*1.15\n",
    "    last_price =( purchasing_cost + international_freight + liRUN )/7.2/0.85\n",
    "    return last_price\n",
    "\n",
    "# print(compute_price(1.65,7,1))\n",
    "print(compute_price(27,0,1))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "24.559378468368482\n"
     ]
    }
   ],
   "source": [
    "# cannada\n",
    "def get_fee_config_v1():\n",
    "    fees = [\n",
    "        {\n",
    "            \"start\": 0,\n",
    "            \"end\": 0.3,\n",
    "            \"yunFee\": 133,\n",
    "            \"guahaoFee\": 23,\n",
    "        },\n",
    "        {\n",
    "            \"start\": 0.3,\n",
    "            \"end\": 0.5,\n",
    "            \"yunFee\": 133,\n",
    "            \"guahaoFee\": 23,\n",
    "        },\n",
    "        {\n",
    "            \"start\": 0.5,\n",
    "            \"end\": 1.5,\n",
    "            \"yunFee\": 140,\n",
    "            \"guahaoFee\": 23,\n",
    "        },\n",
    "        {\n",
    "            \"start\": 1.5,\n",
    "            \"end\": 2,\n",
    "            \"yunFee\": 133,\n",
    "            \"guahaoFee\": 38,\n",
    "        },\n",
    "        {\n",
    "            \"start\": 2,\n",
    "            \"end\": 30,\n",
    "            \"yunFee\": 134,\n",
    "            \"guahaoFee\": 40,\n",
    "        }\n",
    "    ]\n",
    "    return fees\n",
    "def get_fee(weight):\n",
    "    fees = get_fee_config_v1()\n",
    "    for fee in fees:\n",
    "        if weight > fee[\"start\"] and weight <= fee[\"end\"]:\n",
    "            return fee[\"yunFee\"], fee[\"guahaoFee\"]\n",
    "    \n",
    "    return 0,0\n",
    "\n",
    "def compute_price(original_price: '原价',express_freight: '国内快递费',product_weight: '重量')->float:\n",
    "    \"\"\"\n",
    "    Args:\n",
    "    original_price: 原价\n",
    "    express_freight: 国内快递费\n",
    "    product_weight: 重量\n",
    "    # 采购成本：3.5+8=11.5\n",
    "    # 产品重量：0.06+0.05=0.11\n",
    "    # 国际运费：产品重量0.11x运费97+挂号费18=28.67 x 中转仓1.15=32.97\n",
    "    # 商品定价：采购成本11.5+国际运费32.97+利润30=74.47 ÷ canada汇率7.2=10.34÷佣金0.85 = 12.16\n",
    "\n",
    "    #原价\n",
    "    # originalPrice = 3.5\n",
    "    #国内快递费\n",
    "    # expressFreight = 11.5\n",
    "    #采购成本\n",
    "    \"\"\"\n",
    "    purchasing_cost = original_price + express_freight\n",
    "\n",
    "    #产品重量\n",
    "    #product_weight = 0.06\n",
    "    weight_fix = 0.05\n",
    "    weight = product_weight + weight_fix\n",
    "    fee = get_fee(weight)\n",
    "    yunfei = fee[0]\n",
    "    guahaofei = fee[1]\n",
    "    \n",
    "    liRUN = 30\n",
    "    if yunfei <= 0 and guahaofei <=0 :\n",
    "        raise ValueError(\"费用异常\")\n",
    "    international_freight = (weight * yunfei + guahaofei)*1.15\n",
    "    last_price =( purchasing_cost + international_freight + liRUN )/5.3/0.85\n",
    "    return last_price\n",
    "\n",
    "# print(compute_price(1.65,7,0.15))\n",
    "print(compute_price(20,3.6,0.15))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "美丽多彩的花儿，温馨浪漫的气息，，，\n"
     ]
    }
   ],
   "source": [
    "\n",
    "strs = '''美丽多彩的花儿\n",
    "温馨浪漫的气息\n",
    "\n",
    "\n",
    "'''\n",
    "str1 = strs.replace(\" \", \",\").replace(\"\\n\", \"，\").replace(\",\",\"，\").replace(\" \",\"\")\n",
    "print(str1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Pearl earrings  women's personalized earrings  simple and versatile ear hooks  high-end and elegant earrings\n"
     ]
    }
   ],
   "source": [
    "strs = \"Pearl earrings, women's personalized earrings, simple and versatile ear hooks, high-end and elegant earrings\" \n",
    "str1 = strs.replace(\"\\n\", \"\").replace(\",\",\" \")\n",
    "print(str1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['跨境', '热销', '新品上市', '畅销书', '热销', '最受欢迎的', '100%质量', '有史以来最好的', '批发', '黄jin交易日', '高质量', '最佳评分', '退款', '提供不同颜色', '自定义大小', '全球免费送货', '2到3天发货', '好价格', '买2送1', '保证或退款', '大甩卖', '当日优惠', '放心', '免费送货', '所有尺寸和样式', '不可错过', '限量版', '纳米', '热销', '创意', '推荐', '风格类的词', '爆款', 'ins', '抖音', '电商名称', '国别', '地域', '婴儿', '儿童', '宝宝']\n",
      "\n",
      "珍珠耳环女气质个性耳坠长款简约百搭耳钩 高档优雅\n",
      "\n"
     ]
    }
   ],
   "source": [
    "words =\"跨境,热销、新品上市、畅销书、热销、最受欢迎的、100%质量、有史以来最好的、批发、黄jin交易日、高质量、最佳评分、退款、提供不同颜色、自定义大小、全球免费送货、2到3天发货、好价格、买2送1、保证或退款、大甩卖、当日优惠、放心、免费送货、所有尺寸和样式、不可错过、限量版、纳米，热销，创意，推荐，风格类的词，爆款，ins，抖音，电商名称，国别，地域，婴儿，儿童，宝宝\"\n",
    "input=\"高端pu郁金香假花 专供家居酒店婚礼摄影道具手感仿真花\"\n",
    "input='''\n",
    "珍珠耳环女气质个性耳坠长款简约百搭耳钩 高档优雅\n",
    "'''\n",
    "wordList = words.replace(\"、\",\",\").replace(\"，\",\",\").split(\",\")\n",
    "print(wordList)\n",
    "\n",
    "for word in wordList:\n",
    "    input = input.replace(word,\"\")\n",
    "print(input)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
